/*
 * SessionFactory.java
 */

package xq.session;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 *
 * @author ThorntonRP
 */
public abstract class SessionFactory {

	public static SessionFactory getInstance() {
		ServiceLoader<SessionFactory> services = ServiceLoader.load(SessionFactory.class);
		Iterator<SessionFactory> iterator = services.iterator();
		if (iterator.hasNext()) {
			return iterator.next();
		} else {
			throw new IllegalStateException("No session factory could be discovered.");
		}
	}

	public abstract Session getSession();
}
